package cn.wolfcode.trip.base.service.impl;


import cn.wolfcode.trip.base.domain.Information;
import cn.wolfcode.trip.base.mapper.InformationMapper;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.IInformationService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
public class InformationServiceImpl implements IInformationService{
    @Autowired
    private InformationMapper informationMapper;

    @Override
    public void saveOrUpdate(Information information) {
            //保存消息产生的时间
            information.setCreateTime(new Date());

            informationMapper.insert(information);


    }


    @Override
    public PageInfo query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize(), qo.getOrderBy());
        List<Map> list = informationMapper.selectAll(qo);
        return new PageInfo(list);
    }

    @Override
    public Information selectById(Long id) {
        return informationMapper.selectByPrimaryKey(id);
    }
    


}
